#include<bits/stdc++.h>
using namespace std;
const int N = 1e3;
int a[N];
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n;i++){
		cin >> a[i];
	}
	int sum = 0;
	for(int i = 1; i < n - 1;i++){
		int x = a[i-1] > a[i] ? 1 : -1;
		int y = a[i] > a[i + 1] ? 1 : -1; 
		if(x*y < 0)
			sum++;
	}
	cout << sum << endl;
	return 0; 
} 
